Skip to content

NuGet: Fix binding redirect XML parse error to report unparseable file#15147

Merged
brettfo merged 1 commit into
mainfrom
brettfo/fix-binding-redirect-xml-parse-error
May 26, 2026
Merged

NuGet: Fix binding redirect XML parse error to report unparseable file#15147
brettfo merged 1 commit into
mainfrom
brettfo/fix-binding-redirect-xml-parse-error

Conversation

@brettfo
Copy link
Copy Markdown
Contributor

@brettfo brettfo commented May 26, 2026

When updating binding redirects, a failure to parse the XML config file was throwing an InvalidOperationException which resulted in an unknown error being reported to the API (record_update_job_unknown_error).

This change:

  • Catches XmlException specifically and throws UnparseableFileException instead, which is properly mapped to the dependency_file_not_parseable error type
  • Fixes the typo 'binging' → 'binding' in the error message

Testing: Added a test verifying that malformed XML in a config file produces UnparseableFileException with the correct file path and message.

Copilot AI review requested due to automatic review settings May 26, 2026 18:30
@brettfo brettfo requested a review from a team as a code owner May 26, 2026 18:30
@github-actions github-actions Bot added the L: dotnet:nuget NuGet packages via nuget or dotnet label May 26, 2026
@brettfo brettfo force-pushed the brettfo/fix-binding-redirect-xml-parse-error branch from f8c8550 to 3d1c9ae Compare May 26, 2026 18:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves NuGet binding redirect updates by converting XML parse failures in runtime config files into UnparseableFileException, so the updater reports a dependency_file_not_parseable job error instead of an unknown error.

Changes:

  • Catch System.Xml.XmlException during app.config/web.config parsing and rethrow as UnparseableFileException with the config file path.
  • Fix typo in the fallback error message (“binging” → “binding”).
  • Add a unit test asserting malformed XML triggers UnparseableFileException with the expected file path and message.
Show a summary per file
File Description
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs Converts XML parse errors into UnparseableFileException and fixes the binding-redirect error message typo.
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs Adds coverage to ensure malformed config XML is surfaced as UnparseableFileException.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

When updating binding redirects, a failure to parse the XML config file
was throwing an InvalidOperationException which resulted in an unknown
error being reported. This change catches XmlException specifically and
throws UnparseableFileException instead, which is properly mapped to the
dependency_file_not_parseable error type.

Also fixes the typo 'binging' -> 'binding' in the error message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@brettfo brettfo force-pushed the brettfo/fix-binding-redirect-xml-parse-error branch from 3d1c9ae to ad68784 Compare May 26, 2026 21:32
@brettfo brettfo merged commit 23048bb into main May 26, 2026
106 checks passed
@brettfo brettfo deleted the brettfo/fix-binding-redirect-xml-parse-error branch May 26, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: dotnet:nuget NuGet packages via nuget or dotnet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants